package com.hxd.otc.module.my.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.hxd.otc.R;
import com.hxd.otc.base.BaseAdapter;
import com.hxd.otc.module.my.bean.MerchantsOrderBean;
import com.hxd.otc.utils.ResourceUtil;
import com.hxd.otc.utils.UIUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by lzy on 2018/8/14 0014.
 * description ${商户订单Adapter}
 */
public class MerchantsOrderAdapter extends BaseAdapter<MerchantsOrderAdapter.MerchantsOrderHolder, MerchantsOrderBean> {

    public MerchantsOrderAdapter(Context context) {
        super(context);
    }

    @Override
    protected void onBindHolder(@NonNull MerchantsOrderHolder holder, int position) {
        MerchantsOrderBean item = getItem(position);
        holder.tvBillCode.setText(item.getAmount());
        holder.tvOrderStatus.setText(item.getStatus() == 0 ? UIUtils.getContext().getString(R.string.generated) : UIUtils.getContext().getString(R.string.completed));
        holder.tvOrderStatus.setTextColor(ResourceUtil.getColor(item.getStatus() == 0 ? R.color.color_FFD2A56B : R.color.color_FF5AC792));
        holder.tvNickname.setText(item.getUid());
        holder.tvOrderNo.setText(item.getOrdNo());
        holder.tvDate.setText(item.getCreateTime());
        holder.tvPrice.setText(String.format("%sAEC", item.getAmount()));
    }

    @NonNull
    @Override
    public MerchantsOrderHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new MerchantsOrderHolder(mInflater.inflate(R.layout.item_merchats_order, parent, false));
    }

    static class MerchantsOrderHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_bill_code)
        TextView tvBillCode;
        @BindView(R.id.tv_order_status)
        TextView tvOrderStatus;
        @BindView(R.id.view_hor_line)
        View viewHorLine;
        @BindView(R.id.tv_nickname)
        TextView tvNickname;
        @BindView(R.id.tv_desc)
        TextView tvDesc;
        @BindView(R.id.tv_order_no)
        TextView tvOrderNo;
        @BindView(R.id.tv_price)
        TextView tvPrice;
        @BindView(R.id.tv_date)
        TextView tvDate;
        public MerchantsOrderHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
